<!DOCTYPE html>
<style>
  body {
    height: 10000px;
    width: 10000px;
  }
  ::-webkit-scrollbar {
    width: 0px;
    height: 0px;
  }
</style>

<body></body>

<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<script type="text/javascript">
  'use strict';
   async_test(function(t) {
    window.addEventListener('load', t.step_func(function() {
      document.body.offsetTop; // force layout
      if (window.name != 'verification') {
        assert_array_equals([window.innerWidth, window.innerHeight], [800, 600], 'initial page size is valid');
        if (window.internals) {
          internals.setPageScaleFactor(2);
          assert_array_equals([window.visualViewport.width, window.visualViewport.height], [400, 300], 'page is scaled');
        }

        history.scrollRestoration = 'manual';
        window.scrollTo(100, 200);
        assert_equals(history.scrollRestoration, 'manual');
        assert_array_equals([window.scrollX, window.scrollY], [100, 200]);

        setTimeout(function() {
          window.name = 'verification';
          window.location = "../../../resources/back.html";
        }, 0);
      } else {
        assert_array_equals([window.visualViewport.width, window.visualViewport.height], [400, 300], 'page scale is restored');
        assert_array_equals([window.scrollX, window.scrollY], [0, 0], 'scroll position is not restored');
        // clean up
        window.name = '';
        if (window.internals)
          setTimeout(function() {internals.setPageScaleFactor(1);}, 0);
        t.done();
      }
    }));
  }, 'Setting scrollRestoration to manual should not affect scale restoration');
</script>
